import cv2
import matplotlib.pyplot as plt

# 读取图像
image_path = r"C:\Users\14159\Desktop\data\image\1743389731813.jpg"
image = cv2.imread(image_path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

labels =[
    {"bbox_2d": [608, 610, 640, 623], "label": "license_plate"},
    {"bbox_2d": [836, 472, 865, 485], "label": "license_plate"},
    {"bbox_2d": [1247, 560, 1280, 573], "label": "license_plate"},
    {"bbox_2d": [1022, 406, 1052, 418], "label": "license_plate"},
    {"bbox_2d": [875, 280, 895, 290], "label": "license_plate"},
    {"bbox_2d": [723, 344, 743, 354], "label": "license_plate"},
    {"bbox_2d": [772, 186, 792, 196], "label": "license_plate"},
    {"bbox_2d": [650, 128, 670, 138], "label": "license_plate"},
    {"bbox_2d": [905, 156, 925, 166], "label": "license_plate"},
    {"bbox_2d": [918, 80, 938, 90], "label": "license_plate"},
    {"bbox_2d": [1485, 148, 1505, 158], "label": "license_plate"}
]

# 绘制边界框
for obj in labels:
    x1, y1, x2, y2 = obj["bbox_2d"]
    cv2.rectangle(image, (x1, y1), (x2, y2), (255, 0, 0), 2)
    cv2.putText(image, obj["label"], (x1, y1-10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255,0,0), 1)

# 显示图像
plt.figure(figsize=(12, 8))
plt.imshow(image)
plt.axis('off')
plt.show()